package ch5.ext;

public class Dog extends Pet {

	public Dog(String name, int health, int love, String type) {
		super(name, health, love, type);
	}

	public void catchFlyDisc() {
		super.playWith();
		System.out.println(super.getName() + "在接飞盘");
	}

	@Override
	public final void run() {
		super.run();
		System.out.println("撒开四条狗腿，往前跑");
	}

	@Override
	public void shout() {
		// super.shout();
		System.out.println("汪汪汪");
	}

	// 逻辑上比较
	// 比较的规则：name和type相同，则认为宠物是相同的
	@Override
	public boolean equals(Object obj) {
		// 用this和obj做比较
		Dog d = (Dog) obj;

		return this.name.equals(d.name) && this.getType().equals(d.getType());
	}
}
